package com.smmisia.auth.utls;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * 邮件发送服务
 * @author: smmisia
 * @date: 2023-08-09
 */
@Service
public class MailService {
    @Value("${spring.mail.username}")
    private String mail_username;

    @Resource
    private JavaMailSender mailSender;

    public void sendDefaultMail(String to, String subject, String content) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(to);//收信人
        message.setSubject(subject);//主题
        message.setText(content);//内容
        message.setFrom(mail_username);//发信人
        mailSender.send(message);
    }
}